namespace Engine.FileFormats3D.C11Syndikat.QADFile
{
    internal class Ground
    {
        #region Private Fields

        private short dirtiness;
        private short frontGrip;
        private ObjectName groundName;
        private short noCollision;
        private EnumNoise noise;
        private short RearGrip;
        private EnumSkidmarks skidmarks;
        private short Stickiness;
        private ObjectName temp;
        private byte[] unknown = new byte[64];
        private byte[] unknown2 = new byte[14];

        #endregion Private Fields

        #region Public Constructors

        public Ground(string name, short frontGrip, short rearGrip, EnumSkidmarks skidmarks, EnumNoise noise)
        {
            this.dirtiness = 0;
            this.frontGrip = frontGrip;
            this.groundName = new ObjectName(name);
            this.noCollision = 0;
            this.noise = EnumNoise.Asphalt;
            this.RearGrip = rearGrip;
            this.skidmarks = EnumSkidmarks.Hard;
            this.Stickiness = 0;
            this.temp = new ObjectName("tempName");
        }

        public Ground()
        {
        }

        #endregion Public Constructors

        #region Internal Methods

        internal static Ground FromStream(System.IO.BinaryReader br)
        {
            Ground ground = new Ground();

            ground.groundName = ObjectName.FromStream(br);
            ground.temp = ObjectName.FromStream(br); //Only to add more 32 Bytes;
            ground.dirtiness = br.ReadInt16();
            ground.frontGrip = br.ReadInt16();
            ground.RearGrip = br.ReadInt16();
            ground.Stickiness = br.ReadInt16();
            ground.noise = (EnumNoise)br.ReadInt16();
            ground.skidmarks = (EnumSkidmarks)br.ReadInt16();
            ground.unknown = br.ReadBytes(64);
            ground.noCollision = br.ReadInt16();
            ground.unknown2 = br.ReadBytes(14);

            return ground;
        }

        internal void Save(System.IO.BinaryWriter bw)
        {
            this.groundName.Save(bw); //ground.groundName = ObjectName.LoadFromStream(br);
            this.temp.Save(bw);//ground.temp = ObjectName.LoadFromStream(br); //Only to add more 32 Bytes;
            bw.Write(this.dirtiness);//ground.dirtiness = br.ReadInt16();
            bw.Write(this.frontGrip);//ground.frontGrip = br.ReadInt16();
            bw.Write(this.RearGrip);//ground.RearGrip = br.ReadInt16();
            bw.Write(this.Stickiness); //ground.Stickiness = br.ReadInt16();
            bw.Write((short)this.noise); //ground.noise = (EnumNoise)br.ReadInt16();
            bw.Write((short)this.skidmarks); //ground.skidmarks = (EnumSkidmarks)br.ReadInt16();
            bw.Write(this.unknown);//ground.unknown = br.ReadBytes(64);
            bw.Write(this.noCollision);//ground.noCollision = br.ReadInt16();
            bw.Write(this.unknown2);//ground.unknown2 = br.ReadBytes(14);
        }

        #endregion Internal Methods
    }
}